﻿using IterationLife.Educations.Models;
using Util;
using Util.Maps;

namespace IterationLife.PlatformBackEnd.AppServices.Dtos.Educations {
    /// <summary>
    /// 科目分类数据传输对象扩展
    /// </summary>
    public static class SubjectCategoryDtoExtension {
        /// <summary>
        /// 转换为科目分类实体
        /// </summary>
        /// <param name="dto">科目分类数据传输对象</param>
        public static SubjectCategory ToEntity( this SubjectCategoryDto dto ) {
            if ( dto == null )
                return new SubjectCategory();
            return dto.MapTo( new SubjectCategory( dto.Id.ToGuid() ) );
        }
        
        /// <summary>
        /// 转换为科目分类数据传输对象
        /// </summary>
        /// <param name="entity">科目分类实体</param>
        public static SubjectCategoryDto ToDto(this SubjectCategory entity) {
            if( entity == null )
                return new SubjectCategoryDto();
            return entity.MapTo(new SubjectCategoryDto());
        }
    }
}
